package cn.mayaslight.common.vo;

import java.util.ArrayList;
import java.util.List;

public class OperaBody {

	private String propertyName;
	private String operaBodyKey;
	private Object propertyValue;
	private OperaBody next;
	private OperaBody pre;
	private OperaBody first;
	
	private OperaBody(String propertyName, String operaBodyKey, Object propertyValue) {
		this.propertyName = propertyName;
		this.operaBodyKey = operaBodyKey;
		this.propertyValue = propertyValue;
	}
	
	public static OperaBody newOperaBody(String propertyName, String operaBodyKey, Object propertyValue){
		OperaBody operaBody = new OperaBody(propertyName, operaBodyKey, propertyValue);
		operaBody.first = operaBody;
		return operaBody;
	}
	
	public OperaBody add(String propertyName, String operaBodyKey, Object propertyValue) {
		this.next = new OperaBody(propertyName, operaBodyKey, propertyValue);
		this.next.setPre(this);
		this.next.setFirst(this.next.getPre().getFirst());
		return this.next;
	}
	
	public List<OperaBody> list() {
		ArrayList<OperaBody> operaBodyList = new ArrayList<OperaBody>();
		OperaBody operaBody = this.getFirst();
		do {
			operaBodyList.add(operaBody);
		}while((operaBody = operaBody.getNext()) != null);
		return operaBodyList;
	}
	
	public String getPropertyName() {
		return propertyName;
	}

	public void setPropertyName(String propertyName) {
		this.propertyName = propertyName;
	}

	public String getOperaBodyKey() {
		return operaBodyKey;
	}

	public void setOperaBodyKey(String operaBodyKey) {
		this.operaBodyKey = operaBodyKey;
	}

	public Object getPropertyValue() {
		return propertyValue;
	}

	public void setPropertyValue(Object propertyValue) {
		this.propertyValue = propertyValue;
	}

	public OperaBody getNext() {
		return next;
	}

	public void setNext(OperaBody next) {
		this.next = next;
	}

	public OperaBody getPre() {
		return pre;
	}

	public void setPre(OperaBody pre) {
		this.pre = pre;
	}

	public OperaBody getFirst() {
		return first;
	}

	public void setFirst(OperaBody first) {
		this.first = first;
	}

}
